package com.zhida.jiyangcenter

import android.webkit.JavascriptInterface
import androidx.annotation.Keep
import chooongg.base.manager.app
import chooongg.base.utils.startActivity
import chooongg.base.utils.toast
import com.zhida.jiyangcenter.mian.MainActivity
import com.zhida.jiyangcenter.utils.SP

@Keep
class WebJSInterface {
    companion object {
        const val JSName = "jiyang"
    }

    @JavascriptInterface
    fun agreeOrDisagreeProtocol(flag: String) {
        if (flag == "0") {
            for (i in app.activityStack.size - 1 downTo 0) {
                app.activityStack[i].finish()
            }
        }else{
            SP.ISYinsi.put(true)
            app.activityTop.startActivity<MainActivity> {  }
        }
    }
    @JavascriptInterface
    fun finish(){
        app.activityTop.finish()
    }
}